package com.lebang.model.enums;

public enum HistoryTaskCategory {
    /**
     * 历史任务分类
     */
    WAIT("待完成", 1),
    SUCCESS("已完成", 2),
    FAIL("未通过",3),
    ;

    private String title;
    private int index;

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public int getIndex() {
        return index;
    }

    public void setIndex(int index) {
        this.index = index;
    }

    private HistoryTaskCategory(String title, int index) {
        this.title = title;
        this.index = index;
    }

    public HistoryTaskCategory getByIndex(int index) {
        for (HistoryTaskCategory e : HistoryTaskCategory.values()) {
            if (e.index == index) {
                return e;
            }
        }
        return null;
    }

    public HistoryTaskCategory getByTitle(String title) {
        if (null == title) {
            return null;
        }
        for (HistoryTaskCategory e : HistoryTaskCategory.values()) {
            if (e.title.equals(title)) {
                return e;
            }
        }
        return null;
    }
}
